/usr/bin/env python
# -*- coding: utf-8 -*-
# Date    : 2017-07-13 08:59:38
# Author  : 湛允鹏
# Link    : 
# Version : $Id$

import time,uuid

from orm import Model,StringField,BooleanField,TextField,FloatField

def(next_id):
    return '%015d%s000'%(int(time.time()*1000),uuid.uuid4().hex)

class User(Model):
    __table__='users'

    id=StringField(primary_key=True, default=next_id, ddl='varchar(100)')
    email=StringField(ddl='varchar(100)')
    passwd=StringField(ddl='varchar(100)')
    admin=BooleanField()
    name=StringField(ddl='varchar(100)')
    image=StringField(ddl='varchar(500)')
    created_at=FloatField(default=time.time)


class Blog(Model):
    __table__='blogs'
    id=StringField(primary_key=True,default=next_id,ddl='varchar(50)')
    user_id=StringField(ddl='varchar(50)')
    user_name=StringField(ddl='varchar(50)')
    user_image=StringField(ddl='varchar500)')
    name=StringField(ddl='varchar(50)')
    summary = StringField(ddl='varchar(200)')
    content=TextField()
    created_at=FloatField(default=time.time)

class Comment(Model):
    __table__='Comment'

    id = StringField(primary_key=True, default=next_id, ddl='varchar(50)')
    blog_id = StringField(ddl='varchar(50)')
    user_id = StringField(ddl='varchar(50)')
    user_name = StringField(ddl='varchar(50)')
    user_image = StringField(ddl='varchar(500)')
    content = TextField()
    created_at = FloatField(default=time.time)